package cn.wolfcode.wolf2w.service.impl;

import cn.wolfcode.domain.Notelist;
import cn.wolfcode.mapper.NotelistMapper;
import cn.wolfcode.query.NotelistQuery;
import cn.wolfcode.service.INotelistService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;

/**
* 帖子列表服务接口实现
*/
@Service
@Transactional
public class NotelistServiceImpl extends ServiceImpl<NotelistMapper,Notelist> implements INotelistService  {


    @Override
    public IPage<Notelist> queryPage(NotelistQuery qo) {
        IPage<Notelist> page = new Page<>(qo.getCurrentPage(), qo.getPageSize());
        QueryWrapper<Notelist> wrapper = Wrappers.<Notelist>query();
        return super.page(page, wrapper);
    }

    @Override
    public void insert(Notelist notelist) {


        Date date = new Date();
        notelist.setCreatetime(date);
        this.save(notelist);
    }
}
